package com.yinian.server.controller;


import com.yinian.common.result.Result;
import com.yinian.pojo.dto.TeachDetailDTO;
import com.yinian.pojo.entity.App;
import com.yinian.pojo.entity.AppModule;
import com.yinian.pojo.entity.TeachDetail;
import com.yinian.server.service.TeachService;
import com.yinian.server.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 *  返回教程详细步骤
 */
@RestController
@RequestMapping("/teach")
@Slf4j
@Api(tags = "教程相关接口")
public class TeachController {

    @Autowired
    private TeachService teachService;



    /**
     * 教程
     *
     * @param
     * @return
     */
    @PostMapping("/get-app")
    @ApiOperation(value = "返回app种类")
    public Result<List<App>> AppCategory() {
        log.info("返回app种类");
        return Result.success(teachService.getApp());
    }

    @GetMapping("/app-module")
    @ApiOperation(value = "返回app下的模块")
    public Result<List<AppModule>> AppModule(@RequestParam(name = "appId") long appId) {
        log.info("返回app下的模块");
        return Result.success(teachService.getAppModule(appId));
    }

    @GetMapping("/app-detail")
    @ApiOperation(value = "返回app模块下的详细步骤")
    public Result<TeachDetailDTO> TeachDetail(@RequestParam(name = "moduleId") long moduleId,@RequestParam("moduleTableName")String moduleTableName) {
        log.info("返回app下的模块的详细步骤");
        return Result.success(teachService.getTeachDetail(moduleId,moduleTableName));
    }

}
